How to Integrate PhonePe Payment Gateway in PHP

Integrate PhonePe Payment Gateway in PHP

Adding a PhonePe payment gateway to a website isn’t just about using PHP code. The process involves several steps, like getting a merchant account for handling payments, getting essential API credentials, and setting up how the payment gateway works.

Suppose you already have a merchant account and API credentials for your PhonePe gateway. In that case, you can follow this example to connect your Phone Pay payment gateway to your PHP website:

ALSO READ: Authorize.Net Payment Gateway Integration using PHP

Before starting first, create your merchant account with PhonePe https://www.phonepe.com/business-solutions/payment-gateway/register/

PhonePe API Credentials

Step 2: Payment request data (Payload)

Step 3: Convert the JSON Payload to Base64 Encoded Payload

Step 4: Calculate X-Verify/Checksum header

👍

UAT OR SANDBOX API

UAT Host URL: https://api-preprod.phonepe.com/apis/pg-sandbox
API End Point: /pg/v1/pay

UAT PAY API URL: https://api-preprod.phonepe.com/apis/pg-sandbox/pg/v1/pay

Are you want to get implementation help, or modify or extend the functionality of this script?

A Tutorialswebsite Expert can do it for you.

Step 5: Complete PHP code to Integrate PhonePe Payment Gateway

You will get test/sandbox API details from this link: https://developer.phonepe.com/v1/docs/uat-testing

Remember to replace ‘YOUR_API_KEY’, ‘YOUR_MERCHANT_ID’, ‘YOUR_ORDER_ID’, ‘YOUR_REDIRECT_URL’, and other placeholders with your actual credentials and data.

This is just a basic starting point; you’ll need to handle the response from PhonePe on the callback page payment-success.php and implement the necessary logic to complete the payment flow according to PhonePe’s API documentation.

Output

PhonePe Payment Gateway Response

PhonePe Transaction details After Success Payment on (payment-success.php)

PhonePe Transaction details

Wrapping Words

These are the simple and easy steps to Integrate PhonePe Payment Gateway in PHP. You can modify and customize code as per your requirements.

Do you want to get implementation help, or modify or extend the functionality of this script? Submit a paid service request

Related Article

Integrate Recurring Stripe Subscription Payment with PHP

Integrate Blockonomics bitcoin payment gateway in PHP

FAQs

How to integrate the PhonePe payment gateway?

Adding a PhonePe gateway to a website isn’t just about using PHP code. The process involves several steps, like getting a merchant account for handling payments, getting essential API credentials, and setting up how the payment gateway works.

How to get the PhonePe test environment and test transactions API details?

You will get test/sandbox API details from this link: https://developer.phonepe.com/v1/docs/uat-testing

What are the PhonePe Test Card Details?

Debit Card

“card_number”: “4622943126146407”, 
“card_type”: “DEBIT_CARD”, 
“card_issuer”: “VISA”,
“expiry_month”: 12, 
“expiry_year”: 2027, 
“cvv”: “936”

Credit Card

“card_number”: “4208585190116667”,
“card_type”: “CREDIT_CARD”,
“card_issuer”: “VISA”,
“expiry_month”: 06,
“expiry_year”: 2027,
“cvv”: “508”

Can I integrate PhonePe Payment Gateway in PHP?

Yes, You can integrate PhonePe Payment Gateway API In PHP. Please follow this link.

How to Register Your Business with PhonePe?

Register your Business with PhonePe Gateway Solution to send money or make payments & get access to over 47+ Crore users. Click Here

Related posts